/**
 * Filename AdvertiseControllrt.java 2020年12月23日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 *
 * @author wuyingchao
 */
package com.ehome.poct.base.controller.banner;

import com.ehome.poct.base.api.dto.banner.*;
import com.ehome.poct.base.api.vo.banner.*;
import com.ehome.poct.base.api.virtual.BannerService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 广告轮播图controller
 *
 * @author muqiu
 * @date 2022/03/02 16:47
 **/
@Api(tags = "首页轮播图")
@ApiSupport(author = "muqiu")
@RequestMapping("/api/banner")
@RestController
public class BannerController {

    @Autowired
    private BannerService bannerService;

    /**
     * 获取用户轮播图列表
     *
     * @return
     */
    @ApiOperation("获取用户轮播图列表")
    @ApiOperationSupport(author = "muqiu")
    @GetMapping("/list")
    public List<BannerVO> listByClinicId(Integer deviceType) {
        return bannerService.list(deviceType);
    }

    /**
     * 广告曝光数增加
     *
     */
    @ApiOperation("图片曝光数增加")
    @ApiOperationSupport(author = "muqiu")
    @PutMapping("/incrExposure")
    public void incrExposureById(@RequestBody BannerExposureDTO dto) {
        bannerService.incrExposureById(dto);
    }

    /**
     * 广告新增
     *
     * @param bannerDTO
     */
    @ApiOperation("广告增加")
    @ApiOperationSupport(author = "muqiu")
    @PostMapping("/add")
    public Boolean incrExposureById(@RequestBody BannerDTO bannerDTO) {
        return bannerService.add(bannerDTO);
    }

    /**
     * 广告相关数据字典
     *
     * @return
     */
    @ApiOperation("广告相关数据字典")
    @ApiOperationSupport(author = "muqiu")
    @GetMapping("/dictData")
    public List<BannerDictDataVO> dictData() {
        return bannerService.getDictData();
    }


    /**
     * 广告详情列表
     *
     * @return
     */
    @ApiOperation("广告详情列表")
    @ApiOperationSupport(author = "muqiu")
    @PostMapping("/list")
    public BannerInfoPageVO getBanners(@RequestBody BannerPageDTO bannerPageDTO) {
        return bannerService.getBanners(bannerPageDTO);
    }

    /**
     * 编辑回显
     *
     * @return
     */
    @ApiOperation("编辑回显")
    @ApiOperationSupport(author = "muqiu")
    @GetMapping("/{id}")
    public BannerInfoVO getById(@PathVariable(value = "id")Long id) {
        return bannerService.getById(id);
    }

    /**
     * 广告禁用和启用
     * @param ableDTO
     * @return
     */
    @ApiOperation("广告禁用和启用")
    @ApiOperationSupport(author = "muqiu")
    @PutMapping("/disable")
    public Boolean disable(@RequestBody BannerAbleDTO ableDTO) {
        return bannerService.disable(ableDTO);
    }

    /**
     * 广告删除
     * @param id
     * @return
     */
    @ApiOperation("广告删除")
    @ApiOperationSupport(author = "muqiu")
    @DeleteMapping("/delete/{id}")
    public Boolean delete(@PathVariable(value = "id") Long id) {
        return bannerService.delete(id);
    }

    /**
     * 查看数据
     * @param bannerDataDTO
     * @return
     */
    @ApiOperation("查看数据")
    @ApiOperationSupport(author = "muqiu")
    @PostMapping("/data")
    public BannerDataVO getData(@RequestBody BannerDataDTO bannerDataDTO) {
        return bannerService.getData(bannerDataDTO);
    }
}